/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package logging.report;

import java.util.Arrays;
import java.util.Collection;
import pgentity.User;

/**
 *
 * @author Salm
 */
public class DataRecord extends PGRecord {
    private final String[] data;
    
    public DataRecord(PGLogCategory category,
            User user, long time, Collection<?> data, int fix) {
        super(category, user, time);
        this.data = toStrings(data, fix);
    }
    
    public static DataRecord make(PGLogCategory category,
            User user, long time, Object... data)
    {
        return new DataRecord(category, user, time, Arrays.asList(data), data.length);
    }
    
    @Override
    protected int logSize() {
        return super.logSize() + len(data);
    }

    @Override
    protected int logFields() {
        return super.logFields() + data.length;
    }

    @Override
    protected void buildLog(StringBuilder builder) {
        super.buildLog(builder);
        for (String dat : data) {
            logField(builder, dat);
        }
    }
}
